package cn.ad.server.persistence.dao;

import java.util.List;

import cn.ad.server.domain.ad.StrategyGeoMap;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

@Component
public interface StrategyGeoMapDao {

	@Results(value = { @Result(column = "id", property = "id", id = true),
			@Result(column = "strategy_id", property = "strategyId"),
			@Result(column = "geo_type", property = "geoType"),
			@Result(column = "geo_id", property = "geoId"),
			@Result(column = "include_mode", property = "includeMode"),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "update_time", property = "updateTime") })
	@Select("select * from strategy_geo_map ")
	List<StrategyGeoMap> findAll();
	
	@Results(value = { @Result(column = "id", property = "id", id = true),
			@Result(column = "strategy_id", property = "strategyId"),
			@Result(column = "geo_type", property = "geoType"),
			@Result(column = "geo_id", property = "geoId"),
			@Result(column = "include_mode", property = "includeMode"),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "update_time", property = "updateTime") })
	@Select("select * from strategy_geo_map where update_time >= #{value}")
	List<StrategyGeoMap> findAfterTime(String warmUpTime);
	
	@Results(value = { @Result(column = "id", property = "id", id = true),
			@Result(column = "strategy_id", property = "strategyId"),
			@Result(column = "geo_type", property = "geoType"),
			@Result(column = "geo_id", property = "geoId"),
			@Result(column = "include_mode", property = "includeMode"),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "update_time", property = "updateTime") })
	@Select("select * from strategy_geo_map where strategy_id = #{value}")
	List<StrategyGeoMap> findGeo(long sid);

	@Results(value = { @Result(column = "id", property = "id", id = true),
			@Result(column = "strategy_id", property = "strategyId"),
			@Result(column = "geo_type", property = "geoType"),
			@Result(column = "geo_id", property = "geoId"),
			@Result(column = "include_mode", property = "includeMode"),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "update_time", property = "updateTime") })
	@Select("select * from strategy_geo_map where strategy_id = #{id} and status = #{status}")
	List<StrategyGeoMap> selectGeo(@Param("id")long id, @Param("status")int status);

}
